package com.lihuacats.bilibili.task.bilibili_task;

import com.lihuacats.bilibili.task.bilibili_task.config.ConfigProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 启动类
 *
 * @author kurisu
 */
@SpringBootApplication
@EnableScheduling
@EnableTransactionManagement
@ComponentScan("com.lihuacats.bilibili.task.bilibili_task.*")
@Configuration
@EnableConfigurationProperties({ConfigProperties.class})
public class BilibiliTaskApplication extends SpringBootServletInitializer {

    private static ConfigurableApplicationContext context;

    public static void main(String[] args) {
        // Customize the spring config location
        System.setProperty("spring.config.additional-location", "optional:file:${user.home}/bilibili/,optional:file:${user.home}/bilibili-dev/");
        context = SpringApplication.run(BilibiliTaskApplication.class, args);
    }


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        System.setProperty("spring.config.additional-location", "optional:file:${user.home}/bilibili/,optional:file:${user.home}/bilibili-dev/");
        return application.sources(BilibiliTaskApplication.class);
    }
}
